package io.renren.modules.canteens.controller;

import io.renren.common.annotation.LogOperation;
import io.renren.common.constant.Constant;
import io.renren.common.page.PageData;
import io.renren.common.utils.ExcelUtils;
import io.renren.common.utils.Result;
import io.renren.common.validator.AssertUtils;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.canteens.dto.AuxiliaryMateriDTO;
import io.renren.modules.canteens.dto.SmallCanteenPurchaseDTO;
import io.renren.modules.canteens.excel.AuxiliaryMateriExcel;
import io.renren.modules.canteens.excel.SmallCanteenPurchaseExcel;
import io.renren.modules.canteens.service.AuxiliaryMateriService;
import io.renren.modules.canteens.service.SmallCanteenPurchaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;


/**
 * 辅材采购表
 *
 * @author 罗胜平 781757616@qq.com
 * @since 1.0.0 2019-11-22
 */
@RestController
@RequestMapping("canteens/auxiliarymateri")
@Api(tags="辅材采购表")
public class AuxiliaryMateriController {
    @Autowired
    private AuxiliaryMateriService auxiliaryMateriService;
    @GetMapping("getOrderList")
    @ApiOperation("小食堂食材采购月报表")
    public Map getOrderList(String createDate ,long canteenId,int limit,int page) {
        Map orderList = auxiliaryMateriService.getOrderList(createDate,canteenId,limit,page);
        return orderList;
    }
    @GetMapping("export")
    @ApiOperation("导出")
    public void export(String createDate ,long canteenId, HttpServletResponse response) throws Exception {
        Map orderList = auxiliaryMateriService.getOrderList(createDate, canteenId, 0, 0);
        List<SmallCanteenPurchaseDTO> orderList1 = (List<SmallCanteenPurchaseDTO>)orderList.get("orderList");
        ExcelUtils.exportExcelToTarget(response, null,orderList1 , SmallCanteenPurchaseExcel.class);

    }

}